﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.Utils;
using System.Collections;
namespace zmMoniter
{

    public partial class frmWizard : DevExpress.XtraEditors.XtraForm
    {

        private mainForm main = null;
        private int iSelCode = -1;
        private bool bIsEditing = false;
        private bool bIsAdding = false;

        struct CmbInfo
        {
            public int _key; public string _text;
            public CmbInfo(int key, string text)
            {
                _key = key; _text = text;
            }
            public override string ToString()
            {
                return _text;
            }
        }
        public frmWizard(mainForm frm)
        {
            InitializeComponent();
            main = frm;

        }

        private void sBtn_Add_Click(object sender, EventArgs e)
        {
            reSetEdit();
            sBtn_Add.Enabled = false;
            sBtn_Edit.Enabled = false;
            sBtn_Save.Enabled = true;
            sBtn_Delete.Enabled = false;
            sBtn_Cancel.Visible = true;
            setEdit(true);
            bIsAdding = true;
        }

        private void sBtn_Edit_Click(object sender, EventArgs e)
        {
            if (iSelCode != -1)
            {
                setEdit(true);
                sBtn_Save.Enabled = true;
                sBtn_Add.Enabled = false;
                sBtn_Cancel.Visible = true;
                bIsEditing = true;
                bIsAdding = false;
            }
            else
                MessageBox.Show("您还没有选择仓面记录！", "编辑仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void sBtn_Delete_Click(object sender, EventArgs e)
        {
            if (iSelCode != -1)
            {
                DialogResult bDelete = MessageBox.Show("您确认需要删除当前所选仓面记录?", "删除仓面提示",
                   MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (bDelete == DialogResult.Yes)
                {
                    if (deleteDeck(iSelCode))
                    {
                        reSetEdit();//重置按钮以及编辑区域
                        reFushData();//刷新表格数据记录
                        main.upDateGraph();
                    }
                    else
                        MessageBox.Show("删除仓面失败！", "删除仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }


            }
            else
                MessageBox.Show("您还没有选择仓面记录！", "编辑仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void sBtn_Save_Click(object sender, EventArgs e)
        {
            bIsEditing = false;
            if (iSelCode != -1)
            {
                //编辑更新
                updateDeck(iSelCode);
            }
            else
            {
                //添加新记录
                addNewDeck();

            }
        }
        private void sBtn_Cancel_Click(object sender, EventArgs e)
        {
            DialogResult bCancel = MessageBox.Show("您确定需要取消新建仓面操作?", "取消新建提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (bCancel == DialogResult.Yes)
            {
                reSetEdit();//重置按钮以及编辑区域
                bIsAdding = false;
                bIsEditing = false;
            }
        }
        private void sBtn_ReSet_Click(object sender, EventArgs e)
        {
            if (iSelCode != -1)
            {
                //编辑更新
                updateDeckGrid(iSelCode);
            }
           
        }
        private void addNewDeck()
        {

            string sName = textEdt_Name.Text;
            string sDam = cbxEdt_Dam.Text;
            string sDamBlock = cbxEdt_DamBlock.Text;
            string sMaxHeight = textEdt_MaxHeight.Text;
            string sMinHeight = textEdt_MinHeight.Text;
            string slayerHeight = textEdt_LayerHeight.Text;
            string sTongID = textEdt_TongMCode.Text;
            string sTongLevel = textEdt_TongLevel.Text;
            string sTongStuffCode = "";
            string sStartDate = dateEdt_Start.Text;
            string sEndDate = dateEdt_End.Text;
            string sDeckArea = textEdt_Area.Text;
            string sPoints = textEdt_Points.Text;//仓面控制点
            string sCtlPoings = textEdt_CtlPoints.Text;//振捣边界点

            string sArtificial = "";
            if (checkEdt_Artificial.Checked)
                sArtificial = "1";
            else
                sArtificial = "0";
            sDam = sDam.Replace("坝段", "");
            if (sName == "")
            {
                MessageBox.Show("请输入仓面名称！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sDamBlock == "" || sDamBlock == "请选择")
            {
                MessageBox.Show("请选择上下游坝块！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sDam == "" || sDam == "请选择")
            {
                MessageBox.Show("请选择坝段！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sMaxHeight == "")
            {
                MessageBox.Show("请输入最高高程！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sMinHeight == "")
            {
                MessageBox.Show("请输入最低高程！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (slayerHeight == "")
            {
                MessageBox.Show("请输入铺层高度！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sPoints == "")
            {
                MessageBox.Show("请输入仓面控制点！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sCtlPoings == "")
            {
                MessageBox.Show("请输入振捣边界点！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sDamBlock == "上坝块")
                sDamBlock = "S";
            else
                sDamBlock = "X";
            
            if (sTongID == "") sTongID = "null";
            if (sTongLevel == "") sTongLevel = "null";
            if (cbxEdt_TongCode.Text == "请选择")
            {
                sTongStuffCode = "null";
            }
            else
            {
                CmbInfo p = new CmbInfo();
                p = (CmbInfo)(cbxEdt_TongCode.SelectedItem);
                sTongStuffCode = p._key.ToString();
            }
            if (sStartDate == "")
                sStartDate = "null";
            else
                sStartDate = "to_date('" + sStartDate + "','YYYY/MM/DD')";
            if (sEndDate == "")
                sEndDate = "null";
            else
                sEndDate = "to_date('" + sEndDate + "','YYYY/MM/DD')";
            if (sDeckArea == "") sDeckArea = "null";


            string sSQL = "SELECT 仓面信息自增长.nextval AS maxid FROM dual";
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            DataTable dt = db.ReturnDataTable(sSQL);
            if (dt == null)//modify by lance 2013-1-20
            {
                MessageBox.Show("数据库连接失败！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Error);//modify by lance 2013-1-20
                return;//modify by lance 2013-1-20
            }
            int iMaxID = -1;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dataRow = dt.Rows[i];
                iMaxID = int.Parse(dataRow["maxid"].ToString());
            }
            if (iMaxID == -1)
                return;
            
            string sLayerGrid = getLayerGrid(sCtlPoings);
            float x = 0;
            float y = 0;
            getSrcPoint(sPoints, ref x, ref y);
            sSQL = "INSERT INTO 仓面信息 (编号,仓面名称,上下游块,坝段,最低高程,最高高程," +
            "振捣边界点,砼标号,砼级配,砼料号,是否人工振捣,铺层厚度,开仓状态,仓面控制点,开仓时间,结束时间,仓面积,原点X,原点Y,层判断点阵)" +
            "VALUES (" + iMaxID.ToString() + ",'" + sName + "','" + sDamBlock + "'," + sDam + "," + sMinHeight +
            "," + sMaxHeight + ",'" + sCtlPoings + "'," + sTongStuffCode + "," + sTongLevel +
            "," + sTongID + "," + sArtificial + "," + slayerHeight +
            ",2,'" + sPoints + "'," + sStartDate + "," + sEndDate +
            "," + sDeckArea + "," + x + "," + y + "," + ":pb)";
            
            int iResult = db.InsertClobValue(sSQL, sLayerGrid);
            if (iResult > 0)
            {
                //MessageBox.Show("新建仓面成功！即将转入振捣参数设置。", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                reSetEdit();
                setEdit(false);
                reFushData();
                iSelCode = iMaxID;
                bIsAdding = false;
                wizardControl1.SelectedPage = wizardPage2;
                main.upDateGraph();
            }
            else
                MessageBox.Show("新建仓面失败！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            db.CloseConn();
        }
        private void getSrcPoint(string sPoints, ref float x, ref float y)
        {
            string[] Pts = sPoints.Split(';');
            float minx=999999999;
            float miny=999999999;
            for (int i = 0; i < Pts.Length; i++)
            {
                string[] sXY = Pts[i].Split(',');
                if (sXY.Length == 2)
                {
                    float fx=float.Parse(sXY[0]);
                    float fy=float.Parse(sXY[1]);
                    minx=minx>fx?fx:minx;
                    miny=miny>fy?fy:miny;
                }
            }
            x = minx;
            y = miny;
        }
        private void updateDeckGrid(int iCode)
        {
            string sCtlPoings = textEdt_CtlPoints.Text;
            string sLayerGrid = getLayerGrid(sCtlPoings);
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();

            string sSQL = "UPDATE 仓面信息 SET 层判断点阵=:pb WHERE 编号=" + iCode;
            int iResult = db.InsertClobValue(sSQL, sLayerGrid);
            if (iResult > 0)
            {
                MessageBox.Show("重置仓面振捣虚拟格网成功", "重置仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            db.CloseConn();
        }
        private void updateDeck(int iCode)
        {
            string sName = textEdt_Name.Text;
            string sDam = cbxEdt_Dam.Text;
            string sDamBlock = cbxEdt_DamBlock.Text;
            string sMaxHeight = textEdt_MaxHeight.Text;
            string sMinHeight = textEdt_MinHeight.Text;
            string slayerHeight = textEdt_LayerHeight.Text;
            string sTongID = textEdt_TongMCode.Text;
            string sTongLevel = textEdt_TongLevel.Text;
            string sTongStuffCode ="";
            string sStartDate = dateEdt_Start.Text;
            string sEndDate = dateEdt_End.Text;
            string sDeckArea = textEdt_Area.Text;
            string sPoints = textEdt_Points.Text;//仓面控制点
            string sCtlPoings = textEdt_CtlPoints.Text;//振捣边界点

            string sArtificial = "";
            if (checkEdt_Artificial.Checked)
                sArtificial = "1";
            else
                sArtificial = "0";
            sDam = sDam.Replace("坝段", "");
            if (sName == "")
            {
                MessageBox.Show("请输入仓面名称！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sDamBlock == "" || sDamBlock == "请选择")
            {
                MessageBox.Show("请选择上下游坝块！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sDam == "" || sDam == "请选择")
            {
                MessageBox.Show("请选择坝段！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sMaxHeight == "")
            {
                MessageBox.Show("请输入最高高程！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sMinHeight == "")
            {
                MessageBox.Show("请输入最低高程！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (slayerHeight == "")
            {
                MessageBox.Show("请输入铺层高度！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sPoints == "")
            {
                MessageBox.Show("请输入仓面控制点！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sCtlPoings == "")
            {
                MessageBox.Show("请输入振捣边界点！", "添加仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (sDamBlock == "上坝块")
                sDamBlock = "S";
            else
                sDamBlock = "X";
            if (sMaxHeight == "") sMaxHeight = "null";
            if (sMinHeight == "") sMinHeight = "null";
            if (slayerHeight == "") slayerHeight = "null";
            if (sTongID == "") sTongID = "null";
            if (sTongLevel == "") sTongLevel = "null";
            
            if (sStartDate == "")
                sStartDate = "null";
            else
                sStartDate = "to_date('" + sStartDate + "','YYYY/MM/DD HH24:MI:SS')";
            if (sEndDate == "")
                sEndDate = "null";
            else
                sEndDate = "to_date('" + sEndDate + "','YYYY/MM/DD HH24:MI:SS')";
            if (sDeckArea == "") sDeckArea = "null";

            if (cbxEdt_TongCode.Text == "请选择")
            {
                sTongStuffCode = "null";
            }
            else
            {
                CmbInfo p = new CmbInfo();
                p = (CmbInfo)(cbxEdt_TongCode.SelectedItem);
                sTongStuffCode = p._key.ToString();
            }
            float x = 0;
            float y = 0;
            getSrcPoint(sPoints, ref x, ref y);
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();

            string sSQL = "UPDATE 仓面信息 SET 仓面名称='" + sName + "',上下游块='" + sDamBlock + "',坝段=" + sDam + ",最低高程=" + sMinHeight + ",最高高程=" + sMaxHeight + "," +
           "振捣边界点='" + sCtlPoings + "',砼料号=" + sTongID + ",砼级配=" + sTongLevel + ",砼标号=" + sTongStuffCode + ",是否人工振捣=" + sArtificial + ",铺层厚度=" + slayerHeight +
           ",仓面控制点='" + sPoints + "',开仓时间=" + sStartDate + ",结束时间=" + sEndDate + ",仓面积=" + sDeckArea + ",原点X=" + x + ",原点Y="+y+" WHERE" +
           " 编号=" + iCode;

            int iResult = db.ExecuteSQL(sSQL);
            if (iResult > 0)
            {
                //MessageBox.Show("修改仓面成功！", "修改仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                sBtn_Edit.Enabled = false;
                sBtn_Delete.Enabled = false;
                sBtn_Save.Enabled = false;
                sBtn_Add.Enabled = true;
                sBtn_Cancel.Visible = false;
                setEdit(false);
                reFushData();
                main.upDateGraph();
            }
            else
                MessageBox.Show("修改仓面失败！", "修改仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            db.CloseConn();
        }
        private void gridCtl_Deck_Load(object sender, EventArgs e)
        {

        }
        public void reFushData()
        {
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();

            string sSQL = "SELECT 仓面信息.编号,仓面信息.仓面名称,仓面信息.上下游块,'坝段'||坝段 AS 坝段,仓面信息.最低高程,仓面信息.最高高程,仓面信息.振捣边界点,仓面信息.砼标号,砼标号.参数 AS 砼标号参数," +
                "仓面信息.砼级配,仓面信息.砼料号,(case when 仓面信息.是否人工振捣=1 then '是' else '否' end) AS 是否人工振捣,仓面信息.铺层厚度,(case when 仓面信息.开仓状态=1 then '开仓' when 仓面信息.开仓状态=0 then '关仓' when 仓面信息.开仓状态=2 then '规划' else '完成' end) AS 开仓状态,仓面信息.仓面控制点,仓面信息.开仓时间,仓面信息.结束时间," +
                "仓面信息.仓面积 FROM 仓面信息 LEFT OUTER JOIN 砼标号 ON 仓面信息.砼标号 = 砼标号.编号 Order by 开仓时间 ASC";
            DataTable dt = db.ReturnDataTable(sSQL);
            db.CloseConn();
            if (dt == null)//modify by lance 2013/1/20
            {
                this.main.siInfo.Caption = "数据库连接失败!";
                return;
            }
            this.main.siInfo.Caption = "";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dataRow = dt.Rows[i];

                string sDamBlock = dataRow["上下游块"].ToString().Trim();
                if (sDamBlock == "S")
                    dataRow["上下游块"] = "上坝块";
                else
                    dataRow["上下游块"] = "下坝块";

            }
            gridCtl_Deck.DataSource = dt;

        }
        private bool deleteDeck(int iDeckCode)
        {
            bool bResult = false;

            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            /*string sSQL = "Select * FROM 铺层信息表 WHERE 仓面号=" + iDeckCode;
            DataTable dt = db.ReturnDataTable(sSQL);
            if (dt != null && dt.Rows.Count > 0)
            {
                bResult = false;
                MessageBox.Show("无法删除仓面，该仓还有振捣相关监控数据！", "删除仓面提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                sSQL = "Delete 仓面信息 WHERE 编号=" + iDeckCode;
                int iResult = db.ExecuteNonQuery(sSQL);
                if (iResult > 0)
                {
                    bResult = true;
                }
                sSQL = "Delete 铺层信息表 WHERE 仓面号=" + iDeckCode;
                iResult = db.ExecuteNonQuery(sSQL);

                sSQL = "Delete 人工振捣记录表 WHERE 仓面号=" + iDeckCode;
                iResult = db.ExecuteNonQuery(sSQL);

                sSQL = "Delete 预警表 WHERE 仓面号=" + iDeckCode;
                iResult = db.ExecuteNonQuery(sSQL);

                sSQL = "Delete 振捣参数控制标准 WHERE 仓面号=" + iDeckCode;
                iResult = db.ExecuteNonQuery(sSQL);
            }*/
            string sSQL = "Delete 仓面信息 WHERE 编号=" + iDeckCode;
            int iResult = db.ExecuteNonQuery(sSQL);
            if (iResult > 0)
            {
                bResult = true;
                sSQL = "Delete 振捣参数控制标准 WHERE 仓面号=" + iDeckCode;
                iResult = db.ExecuteNonQuery(sSQL);
            }
            db.CloseConn();
            return bResult;
        }
        private void reSetEdit()
        {
            sBtn_Edit.Enabled = false;
            sBtn_Delete.Enabled = false;
            sBtn_Save.Enabled = false;
            sBtn_Add.Enabled = true;
            sBtn_Cancel.Visible = false;
            iSelCode = -1;
            textEdt_Name.Text = "";
            cbxEdt_Dam.Text = (string)cbxEdt_Dam.Tag;
            cbxEdt_DamBlock.Text = (string)cbxEdt_DamBlock.Tag;
            textEdt_MaxHeight.Text = "";
            textEdt_MinHeight.Text = "";
            textEdt_LayerHeight.Text = "";
            textEdt_TongMCode.Text = "";
            textEdt_TongLevel.Text = "";
            //textEdt_TongCode.Text = "";
            addTongCode();

            checkEdt_Artificial.Checked = false;
            dateEdt_Start.Text = "";
            dateEdt_End.Text = "";
            textEdt_Area.Text = "";
            textEdt_Points.Text = "";
            textEdt_CtlPoints.Text = "";

            // sBtn_Edit.Enabled = true;
            setEdit(false);
            wizardPage1.AllowNext = false;
        }
        private void addTongCode()
        {
            cbxEdt_TongCode.Properties.Items.Clear();
            cbxEdt_TongCode.Text = (string)cbxEdt_TongCode.Tag;
            cbxEdt_TongCode.Properties.Items.Add(new CmbInfo(1, "C(28)25W6F150"));
            cbxEdt_TongCode.Properties.Items.Add(new CmbInfo(2, "C(90)25W8F150"));
            cbxEdt_TongCode.Properties.Items.Add(new CmbInfo(3, "C(90)15W4F100"));
            cbxEdt_TongCode.Properties.Items.Add(new CmbInfo(4, "C(90)20W6F100"));
            cbxEdt_TongCode.Properties.Items.Add(new CmbInfo(5, "C(90)25W8F100"));
            cbxEdt_TongCode.Properties.Items.Add(new CmbInfo(6, "C(28)25W8F100"));
            cbxEdt_TongCode.Properties.Items.Add(new CmbInfo(7, "C(28)40W8F150"));
            cbxEdt_TongCode.Properties.Items.Add(new CmbInfo(8, "C(28)35W8F150"));
            
        }
        private void frmWizard_Load(object sender, EventArgs e)
        {
            setEdit(false);
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            string sSQL = "SELECT 仓面信息.编号,仓面信息.仓面名称,仓面信息.上下游块,'坝段'||坝段 AS 坝段,仓面信息.最低高程,仓面信息.最高高程,仓面信息.振捣边界点,仓面信息.砼标号,砼标号.参数 AS 砼标号参数," +
                "仓面信息.砼级配,仓面信息.砼料号,(case when 仓面信息.是否人工振捣=1 then '是' else '否' end) AS 是否人工振捣,仓面信息.铺层厚度,(case when 仓面信息.开仓状态=1 then '开仓' when 仓面信息.开仓状态=0 then '关仓' when 仓面信息.开仓状态=2 then '规划' else '完成' end) AS 开仓状态,仓面信息.仓面控制点,仓面信息.开仓时间,仓面信息.结束时间," +
                "仓面信息.仓面积 FROM 仓面信息 LEFT OUTER JOIN 砼标号 ON 仓面信息.砼标号 = 砼标号.编号 Order by 开仓时间 ASC";

            DataTable dt = db.ReturnDataTable(sSQL);
            db.CloseConn();
            if (dt == null)
                return;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dataRow = dt.Rows[i];

                string sDamBlock = dataRow["上下游块"].ToString().Trim();
                if (sDamBlock == "S")
                    dataRow["上下游块"] = "上坝块";
                else
                    dataRow["上下游块"] = "下坝块";

            }
            gridCtl_Deck.DataSource = dt;

        }
        private void setEdit(bool bEdit)
        {
            if (bEdit)
            {
                textEdt_Name.Enabled = true;
                cbxEdt_Dam.Enabled = true;
                cbxEdt_DamBlock.Enabled = true;
                textEdt_MaxHeight.Enabled = true;
                textEdt_MinHeight.Enabled = true;
                textEdt_LayerHeight.Enabled = true;
                textEdt_TongMCode.Enabled = true;
                textEdt_TongLevel.Enabled = true;
                textEdt_TongCode.Enabled = true;
                checkEdt_Artificial.Enabled = true;
                dateEdt_Start.Enabled = false;
                dateEdt_End.Enabled = false;
                textEdt_Area.Enabled = true;
                textEdt_Points.Enabled = true;
                textEdt_CtlPoints.Enabled = true;
                cbxEdt_TongCode.Enabled = true;
            }
            else
            {
                textEdt_Name.Enabled = false;
                cbxEdt_Dam.Enabled = false;
                cbxEdt_DamBlock.Enabled = false;
                textEdt_MaxHeight.Enabled = false;
                textEdt_MinHeight.Enabled = false;
                textEdt_LayerHeight.Enabled = false;
                textEdt_TongMCode.Enabled = false;
                textEdt_TongLevel.Enabled = false;
                textEdt_TongCode.Enabled = false;
                checkEdt_Artificial.Enabled = false;
                dateEdt_Start.Enabled = false;
                dateEdt_End.Enabled = false;
                textEdt_Area.Enabled = false;
                textEdt_Points.Enabled = false;
                textEdt_CtlPoints.Enabled = false;
                cbxEdt_TongCode.Enabled = false;
            }
        }
        private void gridCtl_Deck_Click(object sender, EventArgs e)
        {
            //int inRow = gridView1.FocusedRowHandle;
            //DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hInfo = (GridHitInfo)gridView1.CalcHitInfo(e.X, e.Y);

            //判断光标是否在行范围内  

            //取得选定行信息  
           

        }
        private void gridCtl_Deck_MouseDown(object sender, MouseEventArgs e)
        {

        }

        private void wizardControl1_NextClick(object sender, DevExpress.XtraWizard.WizardCommandButtonClickEventArgs e)
        {
            if (iSelCode == -1)
            {
                MessageBox.Show("您还没有选择仓面记录！", "进入下一步提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void cbxEdt_TongCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            string TongCode = cbxEdt_TongCode.EditValue.ToString();
           
        }
        private void cbxEdt_DamBlock_SelectedIndexChanged(object sender, EventArgs e)
        {
            string damName = cbxEdt_DamBlock.EditValue.ToString();
            cbxEdt_Dam.Properties.Items.Clear();
            cbxEdt_Dam.Text = (string)cbxEdt_Dam.Tag;
            if (damName == "上坝块")
            {
                for (int i = 1; i < 20; i++)
                {
                    cbxEdt_Dam.Properties.Items.Add(new CmbInfo(i, "坝段" + i.ToString()));
                }
            }
            else if (damName == "下坝块")
            {
                for (int i = 2; i < 19; i++)
                {
                    cbxEdt_Dam.Properties.Items.Add(new CmbInfo(i, "坝段" + i.ToString()));
                }
            }
        }

        private void wizardControl1_SelectedPageChanged(object sender, DevExpress.XtraWizard.WizardPageChangedEventArgs e)
        {
            if (wizardPage2 == e.Page && e.PrevPage == wizardPage1)
            {
                reLoadDeckStandInfo(iSelCode);
                getDeviceList();
            }
            else if (wizardPage3 == e.Page && e.PrevPage == wizardPage2)
            {
                if (setStandInfo() == true && saveDevice()==true)
                    getCardList();
            }
            else if (wizardPage1 == e.Page)
            {
                reSetEdit();
            }
        }
       

        /// <summary>
        /// 保存设备
        /// </summary>
        private bool saveDevice()
        {
            bool bRst = false;
            DateTime now = System.DateTime.Now;
            DataTable dtSource1 = (DataTable)gridCtl_Device.DataSource;
            if (dtSource1 == null)
                return bRst;
            DataTable dtSource = dtSource1.Copy();
            DataView dtView = dtSource.DefaultView;
            dtView.RowFilter = "是否启用=1";
            DataTable dt = dtView.ToTable();
            if (dt.Rows.Count == 0)
                return bRst;
            ArrayList al = new ArrayList();
            string planDevices = "";
            foreach (DataRow row in dt.Rows)
            {
               
                string sID = row["编号"].ToString();//设备编号
                if (planDevices == "")
                    planDevices += sID;
                else
                    planDevices += "," + sID;
                //if (!existDeviceRecord(sID))
                //{          
                //    MessageBox.Show(sID + "号设备已占用,请重新分配 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //    return;
                //}
                //else
                //{      
                //    sSQL = "UPDATE 振捣设备基本信息表 SET 仓面号=" + iSelCode + ",是否分配=1 WHERE 编号=" + sID;//设备上线标记
                //    al.Add(sSQL);
                //}       
            }
            string sSQL = "UPDATE 仓面信息 set 规划设备='"+planDevices+"' where 编号="+iSelCode;
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            int x = db.ExecuteSQL(sSQL);
            if (x!= -1)
            {
                bRst = true;
                //MessageBox.Show("振捣设备分配成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("振捣设备分配失败！", "振捣设备分配提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                wizardControl1.SelectedPage = wizardPage2;
            }
            getDeviceList();
            //for (int i = 0; i < al.Count; i++)
            //{
            //    int x = db.ExecuteSQL((string)al[i]);
            //}
            return bRst;
            
        }

        /// <summary>
        /// 保存人工分配
        /// </summary>
        private void saveCardList()
        {
            DateTime now = System.DateTime.Now;
            DataTable dtSource1 = (DataTable)gridControl_Card.DataSource;
            if (dtSource1 == null)
                return;
            DataTable dtSource = dtSource1.Copy();
            DataView dtView = dtSource.DefaultView;
            dtView.RowFilter = "是否启用=1";
            DataTable dt = dtView.ToTable();
            if (dt.Rows.Count == 0)
                return;
            ArrayList al = new ArrayList();
            foreach (DataRow row in dt.Rows)
            {
                string sSQL = "";            
                string sID = row["编号"].ToString();//编号
                if (!existCardRecord(sID))
                {
                    MessageBox.Show(sID + "号人工已占用,请重新分配 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }
                else
                {
                    sSQL = "UPDATE 人工振捣基本信息表 set 仓面号=" + iSelCode + ",是否分配=1 where 编号=" + sID;
                    al.Add(sSQL);                   
                }
            }
            PublicDataCls db = new PublicDataCls();
            db.OpenConn(); 
            for (int i = 0; i < al.Count; i++)
            {
                int x = db.ExecuteSQL((string)al[i]);
            }
            getCardList();
            MessageBox.Show("人工振捣分配成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }


        private bool existCardRecord(string sID)
        {
            bool bResult = false;
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            string sSQL = "SELECT * FROM 人工振捣基本信息表 WHERE (是否在线 = 0) AND (是否分配 = 0) AND (编号 = " + sID + ")";
            if (db.GetRecordCount(sSQL) > 0)
                bResult = true;
            return bResult;
        }


        private bool existDeviceRecord(string sID)
        {
            bool bResult = false;
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            string sSQL = "SELECT * FROM 振捣设备基本信息表 WHERE (使用设备状态 = 0) AND (是否分配 = 0) AND (编号 = "+sID+")";
            if (db.GetRecordCount(sSQL) > 0)
                bResult = true;
            return bResult;
        }
        private void insertDeckStandInfo(int iDeckCode)
        {
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            string sSQL = "insert into 振捣参数控制标准(编号,振捣深度,振捣时间上限,移动步距,容许插入角度偏差," +
                    "仓面号,振捣时间下限,振捣区域容许重合值,振捣区域容许间隔值)" +
                    "VALUES(振捣参数控制标准自增长.nextval,55,35,0.80,15," + iDeckCode + ",15,30,5)";

            if (db.ExecuteSQL(sSQL) > 0)
                vGridCtl_DeckStandInfo.Rows["row_ID"].Properties.Value = -1;
            else
                vGridCtl_DeckStandInfo.Rows["row_ID"].Properties.Value = 0;
        }
        private void reLoadDeckStandInfo(int iDeckCode)
        {
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();

            string sSQL = "select 振捣参数控制标准.*,仓面信息.仓面名称 FROM 振捣参数控制标准 LEFT OUTER JOIN " +
                "仓面信息 ON 振捣参数控制标准.仓面号 = 仓面信息.编号 " +
                "WHERE 振捣参数控制标准.仓面号=" + iDeckCode;

            DataTable dt = db.ReturnDataTable(sSQL);

            if (dt == null || dt.Rows.Count == 0)//modify by lance 2013-1-20
            {
                //新建的仓
                sSQL = "select 编号,仓面名称 FROM 仓面信息 " +
                "WHERE 仓面信息.编号=" + iDeckCode;
                dt = db.ReturnDataTable(sSQL);
                db.CloseConn();
                if (dt.Rows.Count == 0)
                    return;
                DataRow dataRow = dt.Rows[0];
                string sDeckCode = dataRow["编号"].ToString().Trim();
                string sDeckName = dataRow["仓面名称"].ToString().Trim();
                //vGridCtl_DeckStandInfo.DataSource = dt.DefaultView;
                vGridCtl_DeckStandInfo.Rows["row_deckName"].Properties.Value = sDeckName;
                vGridCtl_DeckStandInfo.Rows["row_deckCode"].Properties.Value = sDeckCode;

                vGridCtl_DeckStandInfo.Rows["row_Depth"].Properties.Value = 55;
                vGridCtl_DeckStandInfo.Rows["row_maxTime"].Properties.Value = 35;
                vGridCtl_DeckStandInfo.Rows["row_moveStep"].Properties.Value = 0.80;
                vGridCtl_DeckStandInfo.Rows["row_angleDeviation"].Properties.Value = 15;
                vGridCtl_DeckStandInfo.Rows["row_minTime"].Properties.Value = 15;
                vGridCtl_DeckStandInfo.Rows["row_Coincidence"].Properties.Value = 30;
                vGridCtl_DeckStandInfo.Rows["row_Interval"].Properties.Value = 5;
                insertDeckStandInfo(iDeckCode);
            }
            else
            {
                db.CloseConn();
                //vGridCtl_DeckStandInfo.DataSource = dt.DefaultView;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dataRow = dt.Rows[i];
                    string sID = dataRow["编号"].ToString().Trim();
                    string sTongCode = dataRow["砼标号"].ToString().Trim();
                    string sDepth = dataRow["振捣深度"].ToString().Trim();
                    string smaxTime = dataRow["振捣时间上限"].ToString().Trim();
                    string smoveStep = dataRow["移动步距"].ToString().Trim();
                    string sAngleDeviation = dataRow["容许插入角度偏差"].ToString().Trim();
                    string sDeckCode = dataRow["仓面号"].ToString().Trim();
                    string sDeckName = dataRow["仓面名称"].ToString().Trim();
                    string sminTime = dataRow["振捣时间下限"].ToString().Trim();
                    string sCoincidence = dataRow["振捣区域容许重合值"].ToString().Trim();
                    string sInterval = dataRow["振捣区域容许间隔值"].ToString().Trim();

                    vGridCtl_DeckStandInfo.Rows["row_deckName"].Properties.Value = sDeckName;
                    vGridCtl_DeckStandInfo.Rows["row_tongCode"].Properties.Value = sTongCode;
                    vGridCtl_DeckStandInfo.Rows["row_Depth"].Properties.Value = sDepth;
                    vGridCtl_DeckStandInfo.Rows["row_maxTime"].Properties.Value = smaxTime;
                    vGridCtl_DeckStandInfo.Rows["row_moveStep"].Properties.Value = smoveStep;
                    vGridCtl_DeckStandInfo.Rows["row_angleDeviation"].Properties.Value = sAngleDeviation;
                    vGridCtl_DeckStandInfo.Rows["row_minTime"].Properties.Value = sminTime;
                    vGridCtl_DeckStandInfo.Rows["row_Coincidence"].Properties.Value = sCoincidence;
                    vGridCtl_DeckStandInfo.Rows["row_Interval"].Properties.Value = sInterval;
                    vGridCtl_DeckStandInfo.Rows["row_ID"].Properties.Value = sID;
                    vGridCtl_DeckStandInfo.Rows["row_deckCode"].Properties.Value = sDeckCode;
                    break;
                }
            }

            /* */
        }
       

        private DataTable UpdateDeviceDataTable(DataTable argDataTable)
        {
            if (argDataTable == null)
                return null;
            string planDevice = getPlanDevice(iSelCode);
            if (planDevice != "")
            {
                string[] planDeviceList = planDevice.Split(',');
                for (int i = 0; i < planDeviceList.Length; i++)
                {
                    for (int j = 0; j < argDataTable.Rows.Count; j++)
                    {
                        if (argDataTable.Rows[j]["编号"].ToString() == planDeviceList[i])
                        {
                            argDataTable.Rows[j]["是否启用"] = 1;
                            break;
                        }
                    }
                }
            }

            DataTable dt = new DataTable();
            //克隆表结构
            dt = argDataTable.Clone();
            foreach (DataColumn column in dt.Columns)
            {
                if (column.ColumnName == "是否启用")
                {
                    //修改列类型
                    column.DataType = typeof(Boolean);
                }
            }
            foreach (DataRow oldrow in argDataTable.Rows)
            {
                DataRow row = dt.NewRow();
                row["编号"] = oldrow["编号"];
                row["型号"] = oldrow["型号"];
                row["振动棒数量"] = oldrow["振动棒数量"];
                //row["使用设备状态"] = oldrow["使用设备状态"];
                row["使用状态"] = oldrow["使用状态"];
                //row["标识"] = Convert.ToInt16(oldrow["标识"]);//你改过DataType的行          
                row["是否启用"] = Convert.ToBoolean(oldrow["是否启用"]);//你改过DataType的行
                dt.Rows.Add(row);
            }
            return dt;
        }

        /// <summary>
        /// 获取规划设备
        /// </summary>
        /// <param name="cmCode">仓面号</param>
        private string getPlanDevice(int cmCode)
        {
            string sSQL = @"SELECT   规划设备 FROM  仓面信息 where 编号="+cmCode;
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            DataTable dt = db.ReturnDataTable(sSQL);
            if (dt == null || dt.Rows.Count == 0)
                return "";
            else
                return dt.Rows[0][0].ToString();

        }

        private void getDeviceList()
        {
            string sSQL = @"SELECT 编号, 型号, 振动棒数量, 履带长, 履带宽, 棒头头长, 棒头总长, 使用状态, 0 AS 是否启用 FROM 振捣设备";
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            DataTable dt = db.ReturnDataTable(sSQL);
            db.CloseConn();
            gridCtl_Device.DataSource = UpdateDeviceDataTable(dt);
        }

        private void getCardList()
        {
            string sSQL = @"SELECT   人工振捣基本信息表.编号, 人工振捣基本信息表.RFID, 人工振捣基本信息表.姓名, 
                振捣设备使用状态表.名称 AS 使用状态, 人工振捣基本信息表.联系方式, 0 AS 是否启用
FROM      人工振捣基本信息表 INNER JOIN
                振捣设备使用状态表 ON 人工振捣基本信息表.是否在线 = 振捣设备使用状态表.编号
WHERE   (人工振捣基本信息表.是否在线 = 0) AND (人工振捣基本信息表.是否分配 = 0)";
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            DataTable dt = db.ReturnDataTable(sSQL);
            db.CloseConn();
            gridControl_Card.DataSource = UpdateCardDataTable(dt);
        }

        private DataTable UpdateCardDataTable(DataTable argDataTable)
        {
            if (argDataTable == null)
                return null;
            DataTable dt = new DataTable();
            //克隆表结构
            dt = argDataTable.Clone();
            foreach (DataColumn column in dt.Columns)
            {
                if (column.ColumnName == "是否启用")
                {
                    //修改列类型
                    column.DataType = typeof(Boolean);
                }
            }
            foreach (DataRow oldrow in argDataTable.Rows)
            {
                DataRow row = dt.NewRow();
                row["编号"] = oldrow["编号"];
                row["RFID"] = oldrow["RFID"];
                row["姓名"] = oldrow["姓名"];
                row["联系方式"] = oldrow["联系方式"];
                //row["仓面号"] = oldrow["仓面号"];
                //row["使用设备状态"] = oldrow["使用设备状态"];
                row["使用状态"] = oldrow["使用状态"];
                //row["标识"] = Convert.ToInt16(oldrow["标识"]);//你改过DataType的行          
                row["是否启用"] = Convert.ToBoolean(oldrow["是否启用"]);//你改过DataType的行
                dt.Rows.Add(row);
            }
            return dt;
        }

       

        private bool  setStandInfo()
        {
            bool bRet = false;
            string sDeckName = vGridCtl_DeckStandInfo.Rows["row_deckName"].Properties.Value != null ? vGridCtl_DeckStandInfo.Rows["row_deckName"].Properties.Value.ToString() : "";
            //string sTongCode = vGridCtl_DeckStandInfo.Rows["row_tongCode"].Properties.Value != null ? vGridCtl_DeckStandInfo.Rows["row_tongCode"].Properties.Value.ToString() : "";
            string sDepth = vGridCtl_DeckStandInfo.Rows["row_Depth"].Properties.Value != null ? vGridCtl_DeckStandInfo.Rows["row_Depth"].Properties.Value.ToString() : "";
            string smaxTime = vGridCtl_DeckStandInfo.Rows["row_maxTime"].Properties.Value != null ? vGridCtl_DeckStandInfo.Rows["row_maxTime"].Properties.Value.ToString() : "";
            string smoveStep = vGridCtl_DeckStandInfo.Rows["row_moveStep"].Properties.Value != null ? vGridCtl_DeckStandInfo.Rows["row_moveStep"].Properties.Value.ToString() : "";
            string sAngleDeviation = vGridCtl_DeckStandInfo.Rows["row_angleDeviation"].Properties.Value != null ? vGridCtl_DeckStandInfo.Rows["row_angleDeviation"].Properties.Value.ToString() : "";
            string sminTime = vGridCtl_DeckStandInfo.Rows["row_minTime"].Properties.Value != null ? vGridCtl_DeckStandInfo.Rows["row_minTime"].Properties.Value.ToString() : "";
            string sCoincidence = vGridCtl_DeckStandInfo.Rows["row_Coincidence"].Properties.Value != null ? vGridCtl_DeckStandInfo.Rows["row_Coincidence"].Properties.Value.ToString() : "";
            string sInterval = vGridCtl_DeckStandInfo.Rows["row_Interval"].Properties.Value != null ? vGridCtl_DeckStandInfo.Rows["row_Interval"].Properties.Value.ToString() : "";
            string sID = vGridCtl_DeckStandInfo.Rows["row_ID"].Properties.Value != null ? vGridCtl_DeckStandInfo.Rows["row_ID"].Properties.Value.ToString() : "";
            string sDeckCode = vGridCtl_DeckStandInfo.Rows["row_deckCode"].Properties.Value.ToString();

            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            string sSQL = "";
            if (sID == "0" || sID==null)
            {
                sSQL = "insert into 振捣参数控制标准(编号,振捣深度,振捣时间上限,移动步距,容许插入角度偏差," +
                    "仓面号,振捣时间下限,振捣区域容许重合值,振捣区域容许间隔值)" +
                    "VALUES(振捣参数控制标准自增长.nextval," + "," + sDepth + "," + smaxTime + "," + smoveStep + "," + sAngleDeviation + "," + sDeckCode + "," + sminTime +
                    "," + sCoincidence + "," + sInterval + ")";
                int iResult = db.ExecuteSQL(sSQL);
                if (iResult > 0)
                {
                    //MessageBox.Show("新建振捣参数控制标准成功！", "添加振捣参数控制标准提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    wizardControl1.SelectedPage = wizardPage3;
                    bRet = true;
                }
                else
                {
                    MessageBox.Show("添加振捣参数控制标准失败！", "添加振捣参数控制标准提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    wizardControl1.SelectedPage = wizardPage2;
                    
                }
            }
            else
            {
                sSQL = "UPDATE 振捣参数控制标准 SET 振捣深度=" + sDepth + ",振捣时间上限=" + smaxTime +
                    ",移动步距=" + smoveStep + ",容许插入角度偏差=" + sAngleDeviation + "," +
                    "振捣时间下限=" + sminTime + ",振捣区域容许重合值=" + sCoincidence + ",振捣区域容许间隔值=" + sInterval +
                    " WHERE 仓面号 =" + sDeckCode;
                int iResult = db.ExecuteSQL(sSQL);
                if (iResult > 0)
                {
                    //MessageBox.Show("更新振捣参数控制标准成功！", "更新振捣参数控制标准提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    wizardControl1.SelectedPage = wizardPage3;
                    bRet = true;
                }
                else
                {
                    MessageBox.Show("更新振捣参数控制标准失败！", "更新振捣参数控制标准提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    wizardControl1.SelectedPage = wizardPage2;
                }
            }
            db.CloseConn();
            return bRet;
        }
        private string getLayerGrid(string sPoints)
        {
            DeckGrider deckgrd = new DeckGrider();
            string[] strPoints = sPoints.Split(';');
            for (int i = 0; i < strPoints.Length; i++)
            {
                string[] strXY = strPoints[i].Split(',');
                if (strXY.Length < 2)
                    continue;
                Point pt = new Point(double.Parse(strXY[0]), double.Parse(strXY[1]));
                deckgrd.addPoint(pt);
            }
            return deckgrd.getGridPoint();
        }

        private void repositoryItemCheckEdit1_CheckedChanged(object sender, EventArgs e)
        {
            //CheckEdit ckEdit = (CheckEdit)sender;
            //int inRow = gridView2.FocusedRowHandle;

            //string isonline = gridView2.GetRowCellValue(inRow, "使用状态").ToString();
            //if (isonline == "离线")
            //{
            //    gridView2.SetRowCellValue(inRow, "使用状态", "在线");
            //}
            //else
            //{
            //    gridView2.SetRowCellValue(inRow, "使用状态", "离线");
            //}

            //int i = int.Parse(gridView2.GetRowCellValue(inRow, "标识").ToString());
            //if (i == 1)
            //{
            //    gridView2.SetRowCellValue(inRow, "标识", 0);
            //}
            //else
            //{
            //    gridView2.SetRowCellValue(inRow, "标识", 1);
            //}
        }

        private void repositoryItemCheckEdit3_CheckedChanged(object sender, EventArgs e)
        {
            //CheckEdit ckEdit = (CheckEdit)sender;
            //int inRow = gridView3.FocusedRowHandle;

            //string isonline = gridView3.GetRowCellValue(inRow, "使用状态").ToString();
            //if (isonline == "离线")
            //{
            //    gridView3.SetRowCellValue(inRow, "使用状态", "在线");
            //}
            //else
            //{
            //    gridView3.SetRowCellValue(inRow, "使用状态", "离线");
            //}

            //int i = int.Parse(gridView3.GetRowCellValue(inRow, "标识").ToString());
            //if (i == 1)
            //{
            //    gridView3.SetRowCellValue(inRow, "标识", 0);
            //}
            //else
            //{
            //    gridView3.SetRowCellValue(inRow, "标识", 1);
            //}
        }

        private void wizardControl1_FinishClick(object sender, CancelEventArgs e)
        {
            
            saveCardList(); 
           // this.Hide();
            this.wizardControl1.SelectedPageIndex = 0;
            
          //  MessageBox.Show("保存成功!");
        }
        private void wizardControl1_CancelClick(object sender, CancelEventArgs e)
        {
            this.Hide();
          //  this.wizardPage1.Select();
            this.wizardControl1.SelectedPageIndex =0;
            main.frmManger("2D");
        }
        private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            if (bIsEditing == true)
                return;
            if(bIsAdding==true)
                return;
            int inRow = e.RowHandle;
            if (inRow < 0)
                return;
            
            int iID = int.Parse(gridView1.GetRowCellValue(inRow, "编号").ToString());
            iSelCode = iID;

            string sName = gridView1.GetRowCellValue(inRow, "仓面名称").ToString();
            string sDam = gridView1.GetRowCellValue(inRow, "坝段").ToString();
            string sDamBlock = gridView1.GetRowCellValue(inRow, "上下游块").ToString();
            string sMinHeight = gridView1.GetRowCellValue(inRow, "最低高程").ToString();
            string sMaxHeight = gridView1.GetRowCellValue(inRow, "最高高程").ToString();
            string sCtlPoints = gridView1.GetRowCellValue(inRow, "振捣边界点").ToString();
            string sTongID = gridView1.GetRowCellValue(inRow, "砼标号").ToString();
            string sTongLevel = gridView1.GetRowCellValue(inRow, "砼级配").ToString();
            string sTongStuffCode = gridView1.GetRowCellValue(inRow, "砼料号").ToString();
            string bArtificial = gridView1.GetRowCellValue(inRow, "是否人工振捣").ToString();
            string slayerHeight = gridView1.GetRowCellValue(inRow, "铺层厚度").ToString();
            
            string sPoints = gridView1.GetRowCellValue(inRow, "仓面控制点").ToString();
            string sStartDate = gridView1.GetRowCellValue(inRow, "开仓时间").ToString();
            string sEndDate = gridView1.GetRowCellValue(inRow, "结束时间").ToString();
            string sDeckArea = gridView1.GetRowCellValue(inRow, "仓面积").ToString();

            textEdt_Name.Text = sName;
            cbxEdt_Dam.Text = sDam;
            cbxEdt_DamBlock.Text = sDamBlock;
            textEdt_MaxHeight.Text = sMaxHeight;
            textEdt_MinHeight.Text = sMinHeight;
            textEdt_LayerHeight.Text = slayerHeight;
            textEdt_TongMCode.Text = sTongID;
            textEdt_TongLevel.Text = sTongLevel;
            textEdt_TongCode.Text = sTongStuffCode;
            if (sTongID != "")
                cbxEdt_TongCode.SelectedIndex = int.Parse(sTongID)-1;
            if (bArtificial == "否" || bArtificial == "0")
                checkEdt_Artificial.Checked = false;
            else
                checkEdt_Artificial.Checked = true;
            dateEdt_Start.Text = sStartDate;
            dateEdt_End.Text = sEndDate;
            textEdt_Area.Text = sDeckArea;
            textEdt_Points.Text = sPoints;//仓面控制点
            textEdt_CtlPoints.Text = sCtlPoints;//振捣边界点

            sBtn_Delete.Enabled = true;
            sBtn_Edit.Enabled = true;
            wizardPage1.AllowNext = true;

        }
    }
}